<template>
	<view>
		<view class="cancle-container">
			<c-layout>
				<!-- 头部 -->
				<c-navigation-bar slot="head" :title="$t('orderDetails.cancelTittle')"></c-navigation-bar>
				<!-- 取消订单 -->
				<!-- <view class="goodsInfo" >
					<goodsOrder :goodsDetail="goodsDetail"></goodsOrder>
				</view> -->
				<view class="goodsInfo">
					<view class="productBox" v-for="(sku,index) in goodsDetail.orderSkus" :key="index">
						<view class="productBox_top">
							<view class="productBox-img">
								<u-image :src="$u.file.getMedieUrl(sku.image)" @click="confirm(sku.id)" style="height: 160rpx; width: 160rpx"></u-image>
								<view class="middle-box">
									<uni-tooltip :content="sku.name">
										<view class="productBox-tittle">
											{{ sku.name }}
										</view>
									</uni-tooltip>
									<uni-tooltip :content="sku.goodsDesc">
										<view class="productBox-introl">
											{{ sku.goodsDesc }}
										</view>
									</uni-tooltip>
									<view class="number-box">
										<view class="productBox-price">${{ sku.money }}</view>
										<uni-tooltip :content="sku.intro">
											<view class="productBox-num">X{{ sku.num }}</view>
										</uni-tooltip>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>

				<!-- 取消订单 -->

				<view class="cancle-box">
					<view class="tittle1">{{$t('orderDetails.Reason')}}</view>

					<view class="select">
						<uni-data-select :placeholder="placeholder" width="670rpx" height="96rpx" v-model="value" :localdata="range" @change="change"></uni-data-select>
					</view>
					<view class="tittle2">{{$t('orderDetails.otherReason')}}</view>
					<textarea :placeholder="placeholder1" name="" id="" cols="30" rows="10" v-model="content"></textarea>
					<button type="default" @click="goOkPage">{{$t('orderDetails.cancellation')}}</button>
				</view>
			</c-layout>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			
			appBaseUrl: process.uniEnv.COSHost,
			type: null,
			range: [
				{ value: 0, text: 'Wrong product inform' },
				{ value: 1, text: 'Address information error' },
				{ value: 2, text: 'Too many pictures' },
				{ value: 3, text: 'Consensus' },
				{ value: 4, text: 'Out of stock' },
				{ value: 5, text: 'Other' }
			],
			//输入框
			content: '',
			goodsDetail: {
				price: 198,
				name: 'Roller Rabbit',
				order: '3324502349KJD2343',
				image: '',
				by: 'Black Heart Institution',
				intro: 'Realize Syirian children',
				qty: '1'
			},
			placeholder: this.$t('orderDetails.pleaseChoose'),
			placeholder1: this.$t('orderDetails.pleaseChoose1'),
			//选择框
			value: null,
			
		};
	},
	methods: {
		goOkPage() {
			//向后台传取消订单的原因
			let id = this.goodsDetail.orderInfo.id;
			let data = {
				orderId: this.goodsDetail.orderInfo.id,
				idea: this.value,
				description: this.content,	
			}

			this.$u.post(`/app/shopOrderInfo/cancel`,data).then((r) => {
				if (r.code == 200) {
					uni.navigateTo({
						url: '/pages/paymentCancel/paymentCancel?type=' + 1,
						animationType: 'slide-in-right',
						animationDuration: 300
					});
				}
			});
		},
		change(e) {
			console.log('e:', e);
		},
		getDictType(){
			this.$u.get(`/system/dict/data/type/return_reason`).then((r) => {
				let liss=r.data
				this.range=liss.map(item=>{
				return {
					text: item.dictLabel,
					value: item.dictValue
				}	
				})
				console.log(2321323,this.range);
			});
			
		},
	},
	onLoad(options) {
		this.goodsDetail = JSON.parse(decodeURIComponent(options.data));
		this.type = options.type;
		console.log(this.goodsDetail.orderInfo.id);
		this.getDictType()
	}
};
</script>

<style lang="scss" scoped>
/deep/.uni-scroll-view,
.uni-scroll-view-content {
	height: 92%;
}
.goodsInfo {
	border-bottom: 8rpx solid #f2f3f5;
	.productBox {
		background: #ffffff;
		border-radius: 26rpx 26rpx 26rpx 26rpx;
		opacity: 1;
		border: 1px solid #e1e8e8;
		margin: 40rpx;
		padding: 20rpx;

		.productBox_top {
			display: flex;
			padding-bottom: 10px;
			justify-content: space-between;
			.productBox-img {
				display: flex;
				.middle-box {
					width: 450rpx;
					padding-left: 20rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-around;
					.productBox-tittle {
						font-size: 30rpx;
						color: #000000;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}
					.productBox-introl {
						font-size: 24rpx;
						overflow: hidden;
						text-overflow: ellipsis;
						white-space: nowrap;
					}
					.number-box {
						display: flex;
						justify-content: space-between;
						.productBox-num {
							font-size: 30rpx;
							overflow: hidden;
							text-overflow: ellipsis;
							white-space: nowrap;
							background-color: #dadada;
							border-radius: 12rpx;
							padding: 5rpx;
						}
						.productBox-price {
							font-size: 30rpx;
							color: #000000;
							font-weight: 500;
						}
					}
				}
			}
		}
	}
}
.cancle-box {
	padding: 48rpx 40rpx;
	font-size: 30rpx;
	font-family: SFUIDisplay-Medium-Regular, SFUIDisplay-Medium;
	font-weight: 400;
	color: #212121;
}
/deep/.uni-select {
	width: 670rpx;
	height: 96rpx;
	border: 2rpx solid #d2d2d2;
	border-radius: 20rpx 20rpx 20rpx 20rpx;
	margin: 30rpx 0 40rpx 0;
}
/deep/.uni-select__input-placeholder {
	font-size: 30rpx;
	font-family: SFUIDisplay-Medium-Regular, SFUIDisplay-Medium;
	font-weight: 400;
	color: #212121;
}
.select-amount {
	width: 670rpx;
	height: 96rpx;
	border: 2rpx solid #d2d2d2;
	border-radius: 20rpx 20rpx 20rpx 20rpx;
	margin: 30rpx 0 40rpx 0;
	text-align: center;
	line-height: 96rpx;
	font-size: 30rpx;
	font-family: SFUIDisplay-Regular-Regular, SFUIDisplay-Regular;
	font-weight: 400;
	color: #91909a;
}

textarea {
	width: 100%;
	height: 316rpx;
	border: 2rpx solid #d2d2d2;
	border-radius: 20rpx 20rpx 20rpx 20rpx;
	padding: 30rpx;
	box-sizing: border-box;
	margin: 30rpx 0;
}
/deep/.placeholderClass {
	color: #e3e4e5;
}
button {
	width: 670rpx;
	height: 120rpx;
	font-size: 32rpx;
	position: fixed;
	bottom: 58rpx;
	right: 0;
	left: 0;
}
</style>
